//
//  XHFindViewController.m
//  Big Show
//
//  Created by 赵晓航 on 15-5-13.
//  Copyright (c) 2015年 Big_Q. All rights reserved.
//

#import "XHFindViewController.h"
#import "WXDetailViewController.h"
#import "WXFindCollectionViewCell.h"
@interface XHFindViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UILabel *label;
@end

@implementation XHFindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    self.navigationItem.title = @"首页";
    self.navigationController.navigationBar.translucent = NO;
    [self creatCollectionView];
    
    

}
// 创建collectionView
-(void)creatCollectionView
{
    
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:flowLayout];
    collectionView.backgroundColor = [UIColor colorWithRed:arc4random()%256/255.0 green:arc4random()%256/255.0 blue:arc4random()%256/255.0 alpha:1];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    collectionView.contentInset = UIEdgeInsetsMake(50, 0, 0, 0);
    flowLayout.itemSize = CGSizeMake(355, 190);
    [self.view addSubview:collectionView];
    [collectionView release];
    [flowLayout release];
    [collectionView registerClass:[WXFindCollectionViewCell class] forCellWithReuseIdentifier:@"reuse"];
    
    self.label = [[UILabel alloc] init];
    _label.text = @"从此刻起,找回最纯粹的自己";
//        _label.backgroundColor = [UIColor greenColor];
    _label.frame = CGRectMake(35,-40, self.view.frame.size.width, 30);
    [_label setFont:[UIFont systemFontOfSize:25]];
    [collectionView addSubview:_label];
    [_label release];
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 12;
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    WXFindCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuse" forIndexPath:indexPath];
    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    WXDetailViewController *detailVC = [[[WXDetailViewController alloc] init] autorelease];
        [self.navigationController pushViewController:detailVC animated:YES];
}

//cell的尺寸
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return CGSizeMake(365, 150);
}

// 外边距
-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
{
    return  UIEdgeInsetsMake(15, 0, 10, 5);
}
// 内面行距
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{
    return 50;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
